﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Data.Models.Center;
using FineUI;
using SysManage.BLL;
using ZHDJ.WebPage;

namespace ZHDJ.Web.Portal.PhotoWall
{
    public partial class PhotoWallList : PageBase
    {
        #region 页面属性

        private string DataTitle
        {
            get
            {
                return Server.UrlDecode(this.Request["DataTitle"] ?? "");
            }
        }

        private string Category
        {
            get
            {
                return Server.UrlDecode(this.Request["Category"] ?? "1");  //1为党员活动
            }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                LoadData();
            }
        }

        #region 数据操作
        private void BindData()
        {
            ControlBusiness.ControlBindDataDictionary(ddlCategory, "ZHDJ.PhotoWall.Category");
            ddlCategory.SelectedValue = this.Category;
            txtTitle.Text = this.DataTitle;
        }

        private void LoadData()
        {
            DataTable dtCount = PartyPhotoWallImage.GetPortalPhotoWallList(0, 0, this.Category, this.DataTitle);
            int sumCount = 0;
            if (dtCount != null)
            {
                sumCount = dtCount.Rows.Count;
            }

            AspNetPager1.RecordCount = sumCount;

            this.Repeater1.DataSource = PartyPhotoWallImage.GetPortalPhotoWallList(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, this.Category, this.DataTitle);
            this.Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            LoadData();
        }

        #endregion

        #region 控件事件
        protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("PhotoWallList.aspx?&Category={0}&DataTitle={1}", ddlCategory.SelectedValue, this.txtTitle.Text));
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("PhotoWallList.aspx?&Category={0}&DataTitle={1}", ddlCategory.SelectedValue, this.txtTitle.Text));
        }
        #endregion
    }
}